package com.kgcx.coupon.controller;

import com.kgcx.common.bean.ReturnData;
import com.kgcx.common.controller.BaseController;
import com.kgcx.coupon.dto.MarketingPlanPushDto;
import com.kgcx.coupon.service.PlanPushService;
import com.kgcx.coupon.vo.coupon.UserPlanVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 何凯
 * @version 0.1
 * @description
 * @time 2017/12/27 14:32
 * @since 0.1
 */
@Api(description = "营销方案推送", tags = "营销方案推送接口")
@RestController
@RequestMapping("coupon/v1/planPush")
public class PlanPushController extends BaseController{
    @Autowired
    private PlanPushService planPushService;
   /**
     * 营销方案推送
     * @param plan
     * @return
     */
    @ApiOperation(value = "营销方案推送", httpMethod = "POST", notes = "营销方案推送接口")
    @PostMapping(value = "save")
	public ReturnData<?> saveUserPlan(@RequestBody UserPlanVO plan) {
		planPushService.saveUserPlanAndCoupon(plan);
		return new ReturnData<>();
	}

	@ApiOperation(value = "营销方案推送页面", httpMethod = "GET", notes = "营销方案推送List页面接口")
	@GetMapping(value = "getList")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "pageNum", value = "页码", required = true, paramType = "query", dataType = "int", dataTypeClass = Integer.class),
			@ApiImplicitParam(name = "pageSize", value = "页容量", required = true, paramType = "query", dataType = "int", dataTypeClass = Integer.class),
			@ApiImplicitParam(name = "userName", value = "用户名", required = false, paramType = "query", dataType = "String", dataTypeClass = String.class),
			@ApiImplicitParam(name = "userPhone", value = "用户电话", required = false, paramType = "query", dataType = "String", dataTypeClass = String.class),
			@ApiImplicitParam(name = "regStartDate", value = "注册开始日期", required = false, paramType = "query", dataType = "Long", dataTypeClass = Long.class),
			@ApiImplicitParam(name = "regEndDate", value = "注册结束日期", required = false, paramType = "query", dataType = "Long", dataTypeClass = Long.class) })
	public ReturnData<?> getList(
			@RequestParam(value = "pageNum", required = true) Integer pageNum,
			@RequestParam(value = "pageNum", required = true) Integer pageSize,
			@RequestParam(value = "userName", required = false) String userName,
			@RequestParam(value = "userPhone", required = false) String userPhone,
			@RequestParam(value = "regStartDate", required = false) Long regStartDate,
			@RequestParam(value = "regEndDate", required = false) Long regEndDate) {
			return planPushService.getList(pageNum, pageSize, userName, userPhone, regStartDate, regEndDate);
	}
}
